import request from '@/utils/request.js'

const prefix = '/api/auth'

// 授权登录方法
export function authLogin(loginCode, phoneCode) {
	return request({
		url: prefix + '/login',
		headers: {
			isToken: false
		},
		method: 'post',
		data: {
			loginCode: loginCode,
			code: phoneCode
		}
	})
}

// 授权登录方法
export function smCodeLogin(loginCode, phone, code) {
	return request({
		url: prefix + '/phoneLogin',
		headers: {
			isToken: false
		},
		method: 'post',
		data: {
			loginCode: loginCode,
			phone: phone,
			code: code
		}
	})
}


// 登录方法
export function login(username, password) {
	const data = {
		username,
		password
	}
	return request({
		url: '/login',
		headers: {
			isToken: false
		},
		method: 'post',
		data: data
	})
}

/**
 * 发送手机验证码
 */
export function sendPhone(phone) {
    return request({
        url: `/sendPhone/${phone}`,
        method: 'post',
    })
}


// 退出方法
export function logout() {
	return request({
		url: '/logout',
		method: 'post'
	})
}